|
1
|
|
|
/* |
|
2
|
|
|
* Circles - Bring cloud-users closer together. |
|
3
|
|
|
* |
|
4
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
|
5
|
|
|
* later. See the COPYING file. |
|
6
|
|
|
* |
|
7
|
|
|
* @author Maxence Lange <[email protected]> |
|
8
|
|
|
* @copyright 2017 |
|
9
|
|
|
* @license GNU AGPL version 3 or any later version |
|
10
|
|
|
* |
|
11
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
12
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
13
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
14
|
|
|
* License, or (at your option) any later version. |
|
15
|
|
|
* |
|
16
|
|
|
* This program is distributed in the hope that it will be useful, |
|
17
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19
|
|
|
* GNU Affero General Public License for more details. |
|
20
|
|
|
* |
|
21
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
22
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
23
|
|
|
* |
|
24
|
|
|
*/ |
|
25
|
|
|
|
|
26
|
|
|
/** global: OC */ |
|
27
|
|
|
/** global: OCA */ |
|
28
|
|
|
/** global: Notyf */ |
|
29
|
|
|
|
|
30
|
|
|
/** global: actions */ |
|
31
|
|
|
/** global: nav */ |
|
32
|
|
|
/** global: elements */ |
|
33
|
|
|
/** global: curr */ |
|
34
|
|
|
/** global: api */ |
|
35
|
|
|
|
|
36
|
|
|
|
|
37
|
|
|
var resultGroups = { |
|
38
|
|
|
|
|
39
|
|
|
|
|
40
|
|
|
searchGroupsResult: function (response) { |
|
41
|
|
|
|
|
42
|
|
|
elements.groupsSearchResult.children().remove(); |
|
43
|
|
|
|
|
44
|
|
|
if (response === null) { |
|
45
|
|
|
elements.groupsSearchResult.fadeOut(0); |
|
46
|
|
|
return; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
elements.fillGroupsSearch(response.ocs.data.exact.groups, response.ocs.data.groups); |
|
50
|
|
|
if (elements.groupsSearchResult.children().length === 0) { |
|
51
|
|
|
elements.groupsSearchResult.fadeOut(0); |
|
52
|
|
|
return; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
$('.groups_search').on('click', function () { |
|
56
|
|
|
curr.searchGroupSelected = $(this).attr('searchresult'); |
|
57
|
|
|
api.linkGroup(curr.circle, curr.searchGroupSelected, |
|
58
|
|
|
resultGroups.linkGroupResult); |
|
59
|
|
|
}); |
|
60
|
|
|
elements.groupsSearchResult.fadeIn(300); |
|
61
|
|
|
}, |
|
62
|
|
|
|
|
63
|
|
|
|
|
64
|
|
|
linkGroupResult: function (result) { |
|
65
|
|
|
|
|
66
|
|
|
if (result.status === 1) { |
|
67
|
|
|
OCA.notification.onSuccess( |
|
68
|
|
|
t('circles', "Group '{name}' successfully added to the circle", |
|
69
|
|
|
{name: result.name})); |
|
70
|
|
|
|
|
71
|
|
|
nav.displayGroups(result.groups); |
|
72
|
|
|
return; |
|
73
|
|
|
} |
|
74
|
|
|
OCA.notification.onFail( |
|
75
|
|
|
t('circles', "Group '{name}' could not be added to the circle", {name: result.name}) + |
|
76
|
|
|
': ' + ((result.error) ? result.error : t('circles', 'no error message'))); |
|
77
|
|
|
}, |
|
78
|
|
|
|
|
79
|
|
|
|
|
80
|
|
|
levelGroupResult: function (result) { |
|
81
|
|
|
if (result.status === 1) { |
|
82
|
|
|
OCA.notification.onSuccess( |
|
83
|
|
|
t('circles', "Group '{name}' updated", |
|
84
|
|
|
{name: result.name})); |
|
85
|
|
|
|
|
86
|
|
|
nav.displayGroups(result.groups); |
|
87
|
|
|
return; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
nav.displayGroups(''); |
|
91
|
|
|
OCA.notification.onFail( |
|
92
|
|
|
t('circles', "Group '{name}' could not be updated", {name: result.name}) + |
|
93
|
|
|
': ' + |
|
94
|
|
|
((result.error) ? result.error : t('circles', 'no error message'))); |
|
95
|
|
|
}, |
|
96
|
|
|
|
|
97
|
|
|
|
|
98
|
|
|
unlinkGroupResult: function (result) { |
|
99
|
|
|
if (result.status === 1) { |
|
100
|
|
|
|
|
101
|
|
|
elements.mainUIGroupsTable.children("[group-id='" + result.name + "']").each( |
|
102
|
|
|
function () { |
|
103
|
|
|
$(this).hide(300); |
|
104
|
|
|
}); |
|
105
|
|
|
OCA.notification.onSuccess( |
|
106
|
|
|
t('circles', "Group '{name}' successfully removed from the circle", |
|
107
|
|
|
{name: result.name})); |
|
108
|
|
|
return; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
OCA.notification.onFail( |
|
112
|
|
|
t('circles', "Group '{name}' could not be removed from the circle", |
|
113
|
|
|
{name: result.name}) + |
|
114
|
|
|
': ' + |
|
115
|
|
|
((result.error) ? result.error : t('circles', 'no error message'))); |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
}; |
|
119
|
|
|
|